<template>
  <div>
    <el-table :data="tableData" style="width: 100%">
      <el-table-column prop="names" label="岗位名称" width="180"></el-table-column>
      <el-table-column prop="salary" label="薪资水平" width="180"></el-table-column>
      <el-table-column prop="education" label="学历水平"></el-table-column>
      <el-table-column prop="workage" label="工作年限"></el-table-column>
      <el-table-column prop="skills" label="掌握技能"></el-table-column>
      <el-table-column prop="city" label="所在城市"></el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  data() {
    return {
      tableData: []
    };
  },
  mounted() {
    this.fetchData();
  },
  watch: {
    '$route'(to, from) {
      this.fetchData();
    }
  },
  methods: {
    fetchData() {
      const type = this.$route.query.type || 1;
      fetch(`http://127.0.0.1:5000/Ckaifa?type=${type}`)
        .then(response => response.json())
        .then(data => {
          this.tableData = data;
        })
          .catch(error => {
            console.error("Error fetching data:", error);
          });
    }
  }
};
</script>
